package com.hlw.hr_man.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hlw.hr_man.Model.EmployeeModel;
import com.hlw.hr_man.service.EmployeeSrevice;
import com.hlw.hr_man.serviceImpl.EmployeeServiceImpl;
/**
 * 更新员工信息
 * @author Windy--Chow
 *
 */
public class UpdateEmployeecontroller extends HttpServlet {
	EmployeeSrevice employee = new EmployeeServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
        resp.setCharacterEncoding("utf8");
        PrintWriter pw = resp.getWriter();
        String e_number = req.getParameter("e_number");
        String e_name = req.getParameter("e_name");
        String e_sex = req.getParameter("e_sex");
        int  e_age = Integer.parseInt(req.getParameter("e_age"));
        String e_tel = req.getParameter("e_tel");
        String e_email = req.getParameter("e_email");
        String e_address = req.getParameter("e_address");
        String e_birthday = req.getParameter("e_birthday");
        String e_entrydate = req.getParameter("e_entrydate");
        String e_description = req.getParameter("e_description");
        int  dept_id =  Integer.parseInt(req.getParameter("dept_id"));
        int e_id = Integer.parseInt(req.getParameter("e_id"));
        EmployeeModel emp = new EmployeeModel(e_id, e_number, e_name, e_sex, e_age, e_tel, e_email, e_address, e_birthday, e_entrydate, e_description, dept_id);
        
        int flag = employee.updateEmployee(emp);
         pw.write(String.valueOf(flag));
	}
}
